package com.yhx.service.impl;

import com.yhx.iservice.IBusinessService;
import com.yhx.iservice.IMemberService;
import com.yhx.iservice.IOrderService;
import com.yhx.iservice.ISetmealService;
import com.yhx.utils.DateUtils;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class IBusinessServiceImpl implements IBusinessService {

    @Resource
    private IMemberService memberService;
    @Resource
    private IOrderService iOrderService;
    @Resource 
    private ISetmealService iSetmealService;

    @Override
    public Map<String,Object>getBusinessData() {

//        Map<Object, Object> redis11 = stringRedisTemplate.opsForHash().entries("redis1");
//        if(redis11==null) {
//            RedisCustom redis1 = new RedisCustom();
//            HashMap<Object, Object> map = new HashMap<>();
//            map.put("reportDate", DateUtils.getToday());
//            map.put("todayNewMember", memberService.getTodayNewMember());
//            map.put("totalMember", memberService.getTotalMember());
//            map.put("thisWeekNewMember", memberService.getThisWeekNewMember());
//            map.put("thisMonthNewMember", memberService.getThisMonthNewMember());
//            map.put("todayOrderNumber", iOrderService.getTodayOrderNumber());
//            map.put("todayVisitsNumber", iOrderService.getTodayVisitsNumber());
//            map.put("thisWeekOrderNumber", iOrderService.getThisWeekOrderNumber());
//            map.put("thisWeekVisitsNumber", iOrderService.getThisWeekVisitsNumber());
//            map.put("thisMonthOrderNumber", iOrderService.getThisMonthOrderNumber());
//            map.put("thisMonthVisitsNumber", iOrderService.getThisMonthVisitsNumber());
//            map.put("hotSetmeal", iSetmealService.hotSetmeal());
//            redis1.setMap(map);
//            redis1.
//        }
//        return redis11;
        Map<String, Object> map=new HashMap<>();
        //获取今天
        String today = null;
        try {
            today = DateUtils.parseDate2String(DateUtils.getToday(), "yyyy-MM-dd");
        } catch (Exception e) {
            e.printStackTrace();
        }
        map.put("reportDate",today);
        map.put("todayNewMember",memberService.getTodayNewMember().toString());
        map.put("totalMember",memberService.getTotalMember().toString());
        map.put("thisWeekNewMember",memberService.getThisWeekNewMember().toString());
        map.put("thisMonthNewMember",memberService.getThisMonthNewMember().toString());
        map.put("todayOrderNumber",iOrderService.getTodayOrderNumber().toString());
        map.put("todayVisitsNumber",iOrderService.getTodayVisitsNumber().toString());
        map.put("thisWeekOrderNumber",iOrderService.getThisWeekOrderNumber().toString());
        map.put("thisWeekVisitsNumber",iOrderService.getThisWeekVisitsNumber().toString());
        map.put("thisMonthOrderNumber",iOrderService.getThisMonthOrderNumber().toString());
        map.put("thisMonthVisitsNumber",iOrderService.getThisMonthVisitsNumber().toString());
        map.put("hotSetmeal",iSetmealService.hotSetmeal());
       return map;
    }
}
